<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script>
        // 使用构造函数封装对象的属性和方法
        function Student(name, age, email, hobby) {
            this.name = name;
            this.age = age;
            this.email = email;
            this.hobby = hobby;
            this.showName = function () {
                alert(this.name);
            }
        }
        var stu1 = new Student("张三", 18, "zhangsan@163.com", "打球");
        stu1.showName();
        var stu2 = new Student('李四', 19, "lisi@163.com", "看书");
        stu2.showName();
    </script>
</head>
<body>
    
</body>
</html>